/*
 * mana (library)
 * Copyright (c) 2003 Shun Moriya <shun@mnu.sakura.ne.jp>
 *
 * The MIT License
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/*!
 * @file
 * @brief	manaライブラリ内で共通利用されるヘッダーファイル
 *
 * このファイルはmanaライブラリ内で共通利用されるヘッダーファイルです。
 *
 * @author	Shun Moriya <shun@mnu.sakura.ne.jp>
 */

#if !defined(___MANA_DEFINE_H___)
#define ___MANA_DEFINE_H___

#if !defined(___MANA_INFO_H___)
#include "mana_info.h"
#endif

#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

#if defined(NDEBUG)
/*! @brief 引数の数を調べ、一致しない場合はreturnします */
#define MANA_ASSERT_PARAMETER(P, I) {									\
	if(mana_actor_get_argument_count(P) != I)							\
		return;															\
}
/*! @brief initアクション中ならばreturnします */
#define MANA_ASSERT_ILLIGAL_CALL_IN_INIT_ACTION(P) {					\
	if(mana_is_in_init_action(P->parent)){								\
		return;															\
}
#else
/*! @brief 引数の数を調べ、一致しない場合は警告を表示してreturnします */
#if 1
#define MANA_ASSERT_PARAMETER(P, I)										\
	if(mana_actor_get_argument_count(P) != I){							\
		 MANA_PRINT("ERROR: %s: function %s number of arguments %d correct%d\n", mana_actor_get_name(P), mana_actor_get_function_name(P), mana_actor_get_argument_count(P), I);\
		 return;														\
	}
/*! @brief initアクション中ならば警告を表示してreturnします */
#define MANA_ASSERT_CANT_CALL_IN_INIT_ACTION(P)							\
	if(mana_is_in_init_action(P->parent)){								\
		MANA_PRINT("ERROR: %s: init action %s can not call\n", mana_actor_get_name(P), mana_actor_get_function_name(P));\
		return;															\
	}
#else
#define MANA_ASSERT_PARAMETER(P, I)										\
	if(mana_actor_get_argument_count(P) != I){							\
		MANA_PRINT("ERROR: %s: 関数%sの引数の数が%dです。正しい引数の数は%dです。\n", mana_actor_get_name(P), mana_actor_get_function_name(P), mana_actor_get_argument_count(P), I);\
		return;														\
	}
/*! @brief initアクション中ならば警告を表示してreturnします */
#define MANA_ASSERT_CANT_CALL_IN_INIT_ACTION(P)							\
	if(mana_is_in_init_action(P->parent)){								\
		MANA_PRINT("ERROR: %s: initアクション内で %s は使えません。\n", mana_actor_get_name(P), mana_actor_get_function_name(P));\
		return;															\
	}
#endif
#endif

#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) || defined(c_plusplus)
}
#endif

#endif
